/**
 * 
 */
package com.app.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.app.dao.ICornRolesCompetence;
import com.app.dao.po.CornRolesCompetence;
import com.app.service.vo.RuleCVo;

/**
 * @author Administrator
 *
 */
public class CornRolesCompetenceImpl extends HibernateDaoSupport implements
		ICornRolesCompetence {

	/**
	 * 
	 */
	public CornRolesCompetenceImpl() {
		// TODO Auto-generated constructor stub
		logger.info(this.getClass()+" loader");
	}

	
	private static Logger logger = Logger.getLogger(CornRolesCompetenceImpl.class);
	/* (non-Javadoc)
	 * @see com.app.dao.ICornRolesCompetence#deleteList(java.util.List)
	 */
	@Override
	public void deleteList(List<RuleCVo> volist) {
		// TODO Auto-generated method stub
		for(RuleCVo v:volist)
		{
			this.getHibernateTemplate().delete(v.parsePo(new CornRolesCompetence()));
		}
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICornRolesCompetence#getAll()
	 */
	@Override
	public List<RuleCVo> getAll() {
		// TODO Auto-generated method stub
		List<CornRolesCompetence> polist = this.getHibernateTemplate().loadAll(CornRolesCompetence.class);
		List<RuleCVo> volist = new ArrayList<RuleCVo>();
		for(CornRolesCompetence po:polist)
		{
			volist.add((RuleCVo) new RuleCVo().parseVo(po));
		}
		return volist;
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICornRolesCompetence#saveList(java.util.List)
	 */
	@Override
	public void saveList(List<RuleCVo> volist) {
		// TODO Auto-generated method stub
		for(RuleCVo vo:volist)
		{
			this.getHibernateTemplate().save(vo.parsePo(new CornRolesCompetence()));
		}
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICornRolesCompetence#updatelist(java.util.List)
	 */
	@Override
	public void updatelist(List<RuleCVo> volist) {
		// TODO Auto-generated method stub
		for(RuleCVo vo:volist)
		{
			this.getHibernateTemplate().update(vo.parsePo(new CornRolesCompetence()));
		}
	}

	/* (non-Javadoc)
	 * @see com.app.dao.ICornRolesCompetence#listBy(java.lang.String)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<RuleCVo> listBy(String ruleid) {
		// TODO Auto-generated method stub
		String hsql = "from com.app.dao.po.CornRolesCompetence where roleId='"+ruleid+"'";
		List<CornRolesCompetence> polist = this.getHibernateTemplate().find(hsql);
		List<RuleCVo> volist = new ArrayList<RuleCVo>();
		for(CornRolesCompetence po:polist)
		{
			volist.add((RuleCVo) new RuleCVo().parseVo(po));
		}
		return volist;
	}

}
